package bp.App.Demo.WaiGua;

import bp.wf.FlowEventBase;

/**
 * 流程外挂
 * 1.getFlowMark 只要在此方法中返回流程编号(多个用逗号分隔)，就可以绑定流程
 * 2.网页端对应流程基本属性中可以看到自动进行了绑定此类，特别注意：需要在网页端再次点击保存一下
 * 3.流程每个节点生命周期中的事件都可以获取并处理自己的业务
 * 4.流程外挂中主表，从表数据获取，参考事件类：EventDemo
 */
public class WaiGuaFlow extends FlowEventBase
{
    public WaiGuaFlow() throws Exception {
        super();
    }
    /// <summary>
    /// 重写流程标记
    /// </summary>
    @Override
    public String getFlowMark()
    {
        return "";
    } //这个位置可以写多个流程编号 045，046，如果需要修改状态的都可以在这个位置增加流程编号

    /**
     * 重写发送前事件
     * @return
     */
    @Override
    public String SendWhen() throws Exception{
            if (1 == 3)
                throw new Exception( "err@不符合流程发起条件，阻止流程发送。");
            if (1==1)
                return "后端外挂  SendWhen 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID()+ ",流程编号:" + this.getHisNode().getFlowNo();
        return super.SendWhen();
    }
    /// <summary>
    /// 发送成功事件，发送成功时，把流程的待办写入其他系统里.
    /// </summary>
    /// <returns>返回执行结果，如果返回null就不提示。</returns>
    @Override
    public String SendSuccess() throws Exception {
        if (1 == 1)
            return "后端外挂: SendSuccess 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        return super.SendSuccess();
    }
    /**
     * 删除后
     *
     * @return
     */
    @Override
    public String ReturnBefore() {
        try {
            return "后端外挂: ReturnBefore 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return super.ReturnBefore();
    }

    /**
     * 结束后
     *
     * @return
     */
    @Override
    public String FlowOverAfter() throws Exception {

        return "后端外挂: FlowOverAfter 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
    }
    @Override
    public String AfterFlowDel() {
        try {
            return "后端外挂: AfterFlowDel 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return super.AfterFlowDel();
    }
    @Override
    public String  BeforeFlowDel() {
        try{
            return "后端外挂: BeforeFlowDel 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return super.BeforeFlowDel();
    }

    @Override
    public String  UndoneBefore() {
        try {
            return "后端外挂: UndoneBefore 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return super.UndoneBefore();
    }
    @Override
    public String  SaveAfter() {
        try {
            return "后端外挂: SaveAfter 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return super.SaveAfter();
    }

    @Override
    public String  FlowRollBackBefore() {
        try {
            return "后端外挂: FlowRollBackBefore 已经执行成功,节点ID:" + this.getHisNode().getNodeID() + ",WorkID:" + this.getWorkID();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return super.FlowRollBackBefore();
    }

    // 重写事件，完成业务逻辑.
}
